<template>
	<view class="user-info-tab">
		<view class="user-head"><image-cache :imgSrc="userInfo.userHeadUrl" mode="aspectFill"></image-cache></view>

		<view class="user-info-group">
			<view class="nick-group">
				<view class="user-nick">
					{{ userInfo.nickName }}
					<view :class="[userInfo.isVip ? 'icon-VIP' : '']" class="icon iconfont"></view>
				</view>
				<view class="user-setting icon iconfont icon-liebiao" @tap="toEditUser">编辑资料</view>
			</view>
			<view class="user-age">
				{{ userInfo.age }}岁
				<view :class="[userInfo.isAuth ? 'icon-shiming' : '']" class="icon iconfont"></view>
			</view>

			<view class="user-tags">
				我的标签:
				<view class="tags">
					<block v-if="index < 5" v-for="(tag, index) in userInfo.tags" :key="'tag' + index">
						<view :class="[tagClass[index]]">{{ tag }}</view>
					</block>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import imageCache from '../image-cache/image-cache.vue';
export default {
	components: {
		imageCache
	},
	props: {
		userInfo: Object
	},
	data() {
		return {
			tagClass: ['one', 'tow', 'three', 'four', 'five']
		};
	},
	methods: {
		toEditUser() {
			uni.navigateTo({
				url: '../edit-user/edit-user'
			});
		}
	}
};
</script>

<style lang="less" scoped>
.user-info-tab {
	padding: 0 40rpx;
	display: flex;
	flex-direction: row;
	align-items: center;
	background-color: #ffffff;
	margin-bottom: 20rpx;

	.user-head {
		width: 170rpx;
		height: 170rpx;
		margin-right: 20rpx;
		image {
			width: 100%;
			height: 100%;
			border-radius: 50%;
		}
	}

	.user-info-group {
		flex: 1;
		.nick-group {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;

			.user-nick {
				display: flex;
				flex-direction: row;
				align-items: center;
				font-size: 32rpx;
				font-weight: 500;
				color: #333333;

				.icon-VIP::before {
					margin-left: 15rpx;
					color: #fecd0e;
					font-size: 34rpx;
				}
			}

			.user-setting {
				margin-top: 10rpx;
				padding: 8rpx 15rpx;
				color: #999999;
				border: 1rpx solid #999999;
				border-radius: 15rpx;
				font-size: 26rpx;
				line-height: 26rpx;
			}
			.icon-liebiao::before {
				margin-right: 8rpx;
			}
		}

		.user-age {
			font-size: 28rpx;
			color: #999999;
			display: flex;
			flex-direction: row;
			align-items: center;
			.icon-shiming::before {
				margin-left: 15rpx;
				color: #09bb07;
			}
		}

		.user-tags {
			font-size: 28rpx;
			color: #999999;
			margin-bottom: 15rpx;

			.tags {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: start;
				view {
					margin: 0 5rpx;
					padding: 8rpx 12rpx;
					border-radius: 15rpx;
					font-size: 24rpx;
					line-height: 24rpx;
					color: #ffffff;
				}
				.one {
					background: linear-gradient(270deg, #ffa93d 0%, #ffcf60 100%);
				}
				.tow {
					background: linear-gradient(270deg, #fc80a4 0%, #feb7ba 100%);
				}
				.three {
					background: linear-gradient(270deg, #836dff 0%, #c1b4ff 100%);
				}
				.four {
					background: linear-gradient(270deg, #3467f9 0%, #82a8fa 100%);
				}
				.five {
					background: linear-gradient(270deg, #f86090 0%, #f894ba 100%);
				}
			}
		}
	}
}
</style>
